<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/all.min.css" integrity="sha256-mUZM63G8m73Mcidfrv5E+Y61y7a12O5mW4ezU3bxqW4=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"anynone.gitee.io","root":"/","images":"/images","scheme":"Pisces","darkmode":true,"version":"8.7.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta property="og:type" content="website">
<meta property="og:title" content="anynone">
<meta property="og:url" content="https://anynone.gitee.io/page/8/index.html">
<meta property="og:site_name" content="anynone">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="山丘之王">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://anynone.gitee.io/page/8/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"zh-CN","comments":"","permalink":"","path":"page/8/index.html","title":""}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>anynone</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">anynone</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <img src="/images/head.jpg">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">山丘之王</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">22</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">15</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/anynone" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;anynone" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner index posts-expand">

    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://anynone.gitee.io/2022/03/31/linux-ununual-command/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="山丘之王">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="anynone">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/03/31/linux-ununual-command/" class="post-title-link" itemprop="url">linux常用命令----mount和umount设备挂载</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-03-31 22:19:40" itemprop="dateCreated datePublished" datetime="2022-03-31T22:19:40+08:00">2022-03-31</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-09-09 08:09:56" itemprop="dateModified" datetime="2022-09-09T08:09:56+08:00">2022-09-09</time>
      </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <blockquote>
<p>mount用来挂载, umount用来卸载。拔出U盘，弹出光盘前记得umount。这个世界，存在一个事物就有其合理性</p>
</blockquote>
<p><font color="blue">mount </font>  [-t 文件系统] [-L 卷标名] [-o 其他选项] 设备文件名称 挂载点</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 例如</span></span><br><span class="line">mount -t ntfs /dev/sdb1 /mnt/sdb1</span><br></pre></td></tr></table></figure>

<p>  常见分区类型有ext,fat,ntfs. 对应驱动以模块形式放入硬盘。保存在<code>/lib/modules/内核版本号/kernel</code>中，分区类型驱动在fs目录中。比如我目前的系统是mint,分区驱动对应目录为<code>/lib/modules/5.4.0-100-generic/kernel/fs/</code>，如下</p>
<img src="/images/linux-common-command/2022-03-31_22-46.png" alt="2022-03-31_22-46" style="zoom:100%;margin-left:0px;" />

<p>可以看到，mint系统已经包含常见的fat，ntfs等驱动。如果当前系统不包含想要挂载的分区类型驱动，则可能需要重新编译内核。有些文件系统比如ntfs，也可以找三方解决方案，比如安装ntfs-3g来支持ntfs磁盘的挂载。</p>
<ol>
<li>光盘挂载 (<code>/dev/cdrom</code> 或 <code>/dev/sr0</code>)<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// 只读盘挂载</span><br><span class="line">mount -t iso9660 /dev/sr0 /mnt/cdrom</span><br></pre></td></tr></table></figure></li>
</ol>
<ul>
<li>/dev/cdrom是/dev/sr0的软链接，建议直接使用/dev/sr0挂载光盘。</li>
<li>如果光盘没有umount掉，光盘是无法弹出的，切记切记</li>
<li>使用空目录作为挂载点</li>
</ul>
<ol start="2">
<li><p>移动硬盘挂载(/dev/sd*)</p>
 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mount -t vfat -o iocharset=utf8 U盘设备文件名 挂载点 </span><br></pre></td></tr></table></figure>
<p>U盘和硬盘公用设备文件名，所以U盘文件名并不是固定的。磁盘的文件名使用<font color=red>sd</font>开头，比如<font color=red>sda,sdb,sdc</font>等。所以挂载磁盘前，需要查询当前磁盘列表：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 查看磁盘列表，可以看到目前连接了2块内置的固态和一块移动硬盘，移动硬盘设备名称是/dev/sda1</span></span><br><span class="line">fdisk -l</span><br><span class="line"><span class="comment"># 因此对应移动磁盘挂载命令为</span></span><br><span class="line">mount -t vfat -o iocharset=utf8 /dev/sda1 /mnt/upan</span><br></pre></td></tr></table></figure>

<img src="/images/linux-common-command/2.png" alt="2" style="margin-left:0px;" /></li>
<li><p>固定挂载硬盘<br> mount -t命令挂载的磁盘在服务器重启后会丢失，如果是新增加的服务器硬盘则需要持久挂载。固定挂载硬盘的正确操作方式是编辑/etc/fstab文件，使用<font color=red>mount -a</font>命令挂载。大多数人习惯性的使用mount命令直接挂载磁盘。也是很多刚刚接触linux小白经常把系统搞崩溃的点。linux系统启动过程会读取fstab配置，如果fstab配置文件有问题，会由于系统无法挂载磁盘导致系统无法进入。当然，修复就是另外的内容了。需要注意的是，<font color=red>mount -a</font>仅仅挂载/etc/fstab配置文件记录的磁盘中没有被挂载的磁盘。也就意味着，如果新的磁盘已经使用mount -t 命令挂载完成，那么mount -a 命令不会重新挂载，也就不会报错。mount -a 检查新的磁盘配置是否正确时，必须先卸载磁盘后再做。<font color=red>对于固定磁盘的挂载，使用mount -a命令读取/etc/fstab配置来挂载磁盘，不要手动mount -t 挂载磁盘</font></p>
<blockquote>
<p>/etc/fstab文件配置 说明</p>
</blockquote>
 <figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;    &lt;options&gt;         &lt;dump&gt;  &lt;pass&gt;</span><br><span class="line">磁盘文件名      挂载点           驱动名称     选项            是否备份   开机是否fsck磁盘</span><br><span class="line">/dev/sda       /opt            ext4     default             0        0 </span><br></pre></td></tr></table></figure></li>
</ol>
<p>​        磁盘文件名、挂载点、驱动名称和mount -t 命令手动挂载意义相同，这里不再赘述。</p>
<p>​        options(选项)意义如下表，大部分情况无需修改,一般写default即可：<br>​        </p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>atime/noatime</td>
<td>更新访问时间/不更新访问时间。访问分区文件时，是否更新文件的访问时间，默认为更新</td>
</tr>
<tr>
<td>async/sync</td>
<td>异步/同步, 默认是异步</td>
</tr>
<tr>
<td>auto/noauto</td>
<td>自动/手动，mount -a 命令执行时是否自动挂载当前磁盘</td>
</tr>
<tr>
<td>exec/noexec</td>
<td>执行/不执行,设定是否允许文件系统中执行可执行文件，默认是exec</td>
</tr>
<tr>
<td>remount</td>
<td>重新挂载已经挂载的文件系统</td>
</tr>
<tr>
<td>rw/ro</td>
<td>读写/只读，文件系统挂载时是否具有读写权限，默认是rw</td>
</tr>
<tr>
<td>suid/nosuid</td>
<td>具有/不具有SUID权限，默认具有</td>
</tr>
<tr>
<td>user/nouser</td>
<td>运行/不允许普通用户挂载，默认是不允许，只有root可以挂载分区</td>
</tr>
<tr>
<td>usrquota</td>
<td>写入代表文件系统支持用户磁盘配额，默认不支持</td>
</tr>
<tr>
<td>grpquota</td>
<td>写入代表文件系统支持组磁盘配额，默认不支持</td>
</tr>
<tr>
<td>default</td>
<td>同事具有rw,suid,dev,exec,auto,nouser,async等默认参数的设置</td>
</tr>
</tbody></table>
<p>dump和fsck如果不理解，新磁盘默认给0即可</p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/7/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><span class="page-number current">8</span><a class="page-number" href="/page/9/">9</a><span class="space">&hellip;</span><a class="page-number" href="/page/22/">22</a><a class="extend next" rel="next" href="/page/9/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>

</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 2021 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">山丘之王</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  





  





</body>
</html>
